package lab02.test19;

/**
 * Created by 婷婷 on 2017/10/31.
 */
public class Test19 {
    public static void main(String[] args) {
        String characterString = "HelloWorld";

        //将字符串转化为字符数组
        char []changeCharacterString = characterString.toCharArray();
        //创建一个新的对象
        StringBuffer change=new StringBuffer();

        //对字符数组从后到前的的遍历
        for (int i=changeCharacterString.length-1;i>=0;i--){

            if (changeCharacterString[i]>=(char)'a'&& changeCharacterString[i]<='z'){
                change.append(String.valueOf(changeCharacterString[i]).toUpperCase());//将小写字母转化为大写

            }else if (changeCharacterString[i]>='A'&& changeCharacterString[i]<='Z'){

                change.append(String.valueOf(changeCharacterString[i]).toLowerCase());// 将大写字母转化为小写

            }

        }

        System.out.println("大小写及顺序转变后：");
        System.out.println(change);
    }
}
